_smbclient_bins=('smbclient' 'rpcclient' 'smbspool'
                     'smbtree' 'smbcacls' 'smbcquotas' 'smbget' 'net'
                     'nmblookup' 'smbtar')
    # Use samba-pkg as a staging directory for the split packages
    # (This is so RPATHS and symlinks are generated correctly via
    # make install, but the otherwise unsplit pieces can be split)
    _pkgsrc="${SRC}"/samba-pkg
    install -d -m755 "${PKG}"/usr/bin
    for bin in ${_smbclient_bins[@]}; do
        mv "${_pkgsrc}"/usr/bin/${bin} "${PKG}"/usr/bin/
    done

    # smbclient binaries link to the majority of the samba
    # libs, so this is a shortcut instead of resolving the
    # whole dependency tree by hand
    install -d -m755 "${PKG}"/usr/lib
    for lib in "${_pkgsrc}"/usr/lib/lib*.so*; do
        mv ${lib} "${PKG}"/usr/lib/
    done

    install -d -m755 "${PKG}"/usr/lib/samba
    for lib in "${_pkgsrc}"/usr/lib/samba/lib*.so*; do
        mv ${lib} "${PKG}"/usr/lib/samba/
    done

    install -d -m755 "${PKG}"/usr/lib/pkgconfig
    mv "${_pkgsrc}"/usr/lib/pkgconfig/smbclient.pc "${PKG}"/usr/lib/pkgconfig/
    mv "${_pkgsrc}"/usr/lib/pkgconfig/netapi.pc "${PKG}"/usr/lib/pkgconfig/
    mv "${_pkgsrc}"/usr/lib/pkgconfig/wbclient.pc "${PKG}"/usr/lib/pkgconfig/

    install -d -m755 "${PKG}"/usr/share/man/man1
    install -d -m755 "${PKG}"/usr/share/man/man7
    install -d -m755 "${PKG}"/usr/share/man/man8
    for bin in ${_smbclient_bins[@]}; do
        if [ -e "${_pkgsrc}"/usr/share/man/man1/${bin}.1 ]; then
            mv "${_pkgsrc}"/usr/share/man/man1/${bin}.1 "${PKG}"/usr/share/man/man1/
        fi
        if [ -e "${_pkgsrc}"/usr/share/man/man8/${bin}.8 ]; then
            mv "${_pkgsrc}"/usr/share/man/man8/${bin}.8 "${PKG}"/usr/share/man/man8/
        fi
    done

    install -d -m755 "${PKG}"/usr/include/samba-4.0
    mv "${_pkgsrc}"/usr/include/samba-4.0/libsmbclient.h "${PKG}"/usr/include/samba-4.0/
    mv "${_pkgsrc}"/usr/include/samba-4.0/netapi.h "${PKG}"/usr/include/samba-4.0/
    mv "${_pkgsrc}"/usr/include/samba-4.0/wbclient.h "${PKG}"/usr/include/samba-4.0/

    mkdir -p "${PKG}"/usr/lib/cups/backend
    ln -sf /usr/bin/smbspool "${PKG}"/usr/lib/cups/backend/smb

    # Use samba-pkg as a staging directory for the split packages
    # (This is so RPATHS and symlinks are generated correctly via
    # make install, but the otherwise unsplit pieces can be split)
    _pkgsrc="${SRC}"/samba-pkg
    # Everything that libwbclient and smbclient didn't install goes
    # into the samba package...
    cp -r "${_pkgsrc}"/* "${PKG}"
   # rmdir "${_pkgsrc}"



  # create ephemeral dirs via tmpfiles rather than shipping them in package
  install -D -m644 "${SRC}"/samba.conf "${PKG}"/usr/lib/tmpfiles.d/samba.conf
  # create config dir
  install -d -m755 "${PKG}"/etc/samba

  mkdir -p "${PKG}"/etc/samba/private
  chmod 700 "${PKG}"/etc/samba/private

  install -D -m644 "${SRC}"/samba.logrotate "${PKG}"/etc/logrotate.d/samba
  install -D -m644 "${SRC}"/samba.pam "${PKG}"/etc/pam.d/samba 
  
  # spool directory
  install -d -m1777 "${PKG}"/var/spool/samba
  
  rm -rf "${PKG}"/run
  rm -rf "${PKG}"/var/run
  rm -rf "${PKG}"/etc/sysconfig
  
  # copy ldap example
  install -D -m644 "${SRC}"/samba-${surum}/examples/LDAP/samba.schema "${PKG}"/usr/share/doc/samba/examples/LDAP/samba.schema

  # Fix waf installing the wrong permissions for sudoers.d
  #chmod 750 ${PKG}/etc/sudoers.d
  #chmod 600 ${PKG}/etc/sudoers.d/ctdb
  